<?php

namespace app\admin\controller\information;

use app\common\controller\Backend;

/**
 * 用户档案管理
 *
 * @icon fa fa-circle-o
 */
class U8user extends Backend
{
    /**
     * U8user模型对象
     * @var \app\admin\model\information\U8user
     */
    protected $model = null;
    protected $allUpdate =[];
    protected $searchFields = "cUser_Id,cUser_Name,cDept";
    protected $noNeedLogin = ['index'];
    
    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\information\U8user;
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
    }
    
    public function index()
    {
        if (false === $this->request->isAjax()) {
            return $this->view->fetch();
        }
        //如果发送的来源是 Selectpage，则转发到 Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        
        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
        
        $list = $this->model
        ->where($where)
        ->field('cUser_Id,cUser_Name,cDept')
        ->order($sort, $order)
        ->paginate($limit);
        $result = ['total' => $list->total(), 'rows' => $list->items()];
        return json($result);
    }
}
